<?php
namespace Common\Model;
use Think\Model;
class BaseModel extends Model{
	//伪删除字段
	protected $PDField = '';
	
	//条件
	protected $condition = '';
	
	protected function _initialize(){
		$this->PDField = C('PSEUDO_DELETE_FIELD') ? C('PSEUDO_DELETE_FIELD') : 'is_del';
	}

    /**
     * 获取列表
     * @return array|mixed
     */
    protected function getRows(){
        //创建分页数据
        $page = I('page');
        $page_num = I('rows');
        if($page && $page_num){
            $options = $this->options;
            $data['rows'] = $this->page($page,$page_num)->select();
            $data['count'] = $this->table($options['table'])->where($options['where'])->count();
            !$data['rows'] && $data['rows'] = array();
            $data['error'] = 0;
            return $data;
        }else{
            $rows = $this->select();
            return empty($rows) ? array() : $rows;
        }
    }

}
?>